package br.com.tarlis.core.server;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.tarlis.persistent.server.Factory;

public abstract class ServerAction {
	
	private Map<String, Object> parameters;

	private HttpServletRequest request;
	private HttpServletResponse response;
	
	public abstract Map<String, Object> doAction();
	
	protected HttpServletRequest getRequest() {
		return request;
	}
	
	protected void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	
	protected HttpServletResponse getResponse() {
		return response;
	}
	
	protected void setResponse(HttpServletResponse response) {
		this.response = response;
	}
	
	protected Map<String, Object> getParameters() {
		return parameters;
	}
	
	protected void setParameters(Map<String, Object> parameters) {
		this.parameters = parameters;
	}

	protected void clearParameters() {
		parameters.clear();
	}

	protected boolean containsParameterKey(Object key) {
		return parameters.containsKey(key);
	}

	protected boolean containsParameterValue(Object value) {
		return parameters.containsValue(value);
	}

	protected Object getParameter(String key) {
		return parameters.get(key);
	}

	protected Object putParameter(String key, Object value) {
		return parameters.put(key, value);
	}

	protected void putAllParameters(Map<? extends String, ? extends Object> m) {
		parameters.putAll(m);
	}

	protected Object removeParameter(Object key) {
		return parameters.remove(key);
	}

	protected int parametersSize() {
		return parameters.size();
	}
	
	protected Factory getFactory() {
		// TODO Auto-generated method stub

	}

}
